<?php
 
/*
 * Following code will update a product information
 * A product is identified by product id (pid)
 */
 
// array for JSON response
$response = array();
 
// check for required fields
if (isset($_POST['Comment_Id']) && isset($_POST['Place_Id']) && isset($_POST['User_Id'])&& isset($_POST['Detail_Comment']) && isset($_POST['Time_Comment'])) {
 
    $Comment_Id = $_POST['Comment_Id'];
    $Place_Id = $_POST['Place_Id'];
    $User_Id = $_POST['User_Id'];
    $Detail_Comment	 = $_POST['Detail_Comment'];
    $Time_Comment = $_POST['Time_Comment'];
 
    // include db connect class
    require_once __DIR__ . '/db_connect.php';
 
    // connecting to db
    $db = new DB_CONNECT();
 
    // mysql update row with matched pid
    $result = mysql_query("UPDATE Comment SET Place_Id = '$Place_Id', User_Id = '$User_Id', Detail_Comment = '$Detail_Comment', Time_Comment = '$Time_Comment' WHERE Comment_Id = $Comment_Id");
 
    // check if row inserted or not
    if ($result) {
        // successfully updated
        $response["success"] = 1;
        $response["message"] = "Successfully updated.";
 
        // echoing JSON response
        echo json_encode($response);
    } else {
 
    }
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
 
    // echoing JSON response
    echo json_encode($response);
}
?>